import moment from "moment"
import { articleDetail } from "../../../api/index"
import { resetHtml } from "../../../utils/util"

// pages/article/index.ts
Page({

    /**
     * 页面的初始数据
     */
    data: {
        detailData: {}
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(e: { id: string }) {
        articleDetail(e.id).then((r:any) => {
            r = {
                ...r,
                content:resetHtml(r.content),
                created_at:moment(r.created_at*1000).format("YYYY-MM-DD HH:mm:ss")
            }
            this.setData({ detailData: r })
        })
    },
})